/**
 * 
 */
package com.dmjj.cadcommon.base;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.codehaus.groovy.reflection.ReflectionUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;

/**
 * Description: 抽象数据映射类 <br /> 
 * Project: meirenhui <br />
 * ClassName: AbstractBaseMapper <br />
 * Copyright: Copyright (c) 2017 deshang<br />
 * @author bushy
 * @version 1.0 2017年10月11日下午1:54:15
 */
public abstract class AbstractBaseMapper<T, Ser extends Serializable> implements BaseMapper<T, Ser> {

	@Autowired
	private SqlSessionFactory sqlSessionFactory;
	private Class<?> entityMapperClass;

	@SuppressWarnings("unchecked")
	protected BaseMapper<T, Ser> getBaseMapper() {
		SqlSession sqlSession = sqlSessionFactory.openSession();
		entityMapperClass = ReflectionUtils.getCallingClass();
		BaseMapper<T, Ser> baseMapper = (BaseMapper<T, Ser>) sqlSession.getMapper(entityMapperClass);
		return baseMapper;
	}
}
